package se.tinkerway.bomberman.domain.tile;

import se.tinkerway.bomberman.domain.Bomberman;
import se.tinkerway.bomberman.domain.Tile;
import se.tinkerway.bomberman.domain.TileCallback;
import se.tinkerway.bomberman.view.Appearance;
import se.tinkerway.bomberman.view.Frame;

public class Bomb implements Tile {

	private int bombPower;
	private long timeToExplode;

	public Bomb(int bombPower, long timeToExplode) {
		this.bombPower = bombPower;
		this.timeToExplode = timeToExplode;
	}

	@Override
	public boolean burn(TileCallback callback) {
		callback.explode(bombPower);
		System.out.println("EXPLODE!");
		// TODO: inform bomberman that we exploded
		return true;
	}

	@Override
	public boolean isPassable() {
		return false;
	}

	@Override
	public void onEnter(Bomberman bomberman) {
	}

	@Override
	public void timeTick(long deltaTime, TileCallback callback) {
		timeToExplode -= deltaTime;
		if (timeToExplode <= 0) {
			burn(callback);
		}
	}

	@Override
	public Frame getFrame() {
		return new Frame(0, Appearance.BOMB);
	}

}
